#include "device_select.h"
#include "ui_device_select.h"
#include <QVBoxLayout>
device_select::device_select(QWidget *parent,QStringList dev_list) :
    QWidget(parent),
    ui(new Ui::device_select)
{
    ui->setupUi(this);
    box = new QComboBoxSearch;
    box->addItems(dev_list);

    QWidget * p1 = new QWidget;
    QVBoxLayout* layout1 = new QVBoxLayout(p1);
    layout1->addWidget(box);
    ui->ui_pages->addTab(p1,"dev_type");
}

device_select::~device_select()
{
    delete ui;
}

QStringList device_select::exec()
{
    QEventLoop loop;
    connect(this, &device_select::device_sel_trig, &loop, &QEventLoop::quit);
    loop.exec();

    QStringList list_return;
    list_return.append(box->currentText());
    return list_return; // 返回选中的设备
}

void device_select::on_ui_btm_create_clicked()
{
    emit device_sel_trig();
    this->close();
}


void device_select::on_ui_btm_exit_clicked()
{

    emit device_sel_trig();
    this->close();
}

